package com.school.chapter02.queue_.useless;

import com.school.chapter02.queue_.Queue_;

import java.util.Scanner;
import java.util.Stack;
import java.util.Queue;
import java.io.*;

public class CheckPalindrome {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String line = in.nextLine();
            if (line.toLowerCase().equals("quit")) {

                System.out.println(line);
                break;
            }
            Stack<Character> stack = new Stack<Character>();
            Queue_<Character> queue = new Queue_<Character>();
            for (int i = 0; i < line.length(); i++) {
                stack.push(line.charAt(i));
                queue.enqueue(line.charAt(i));
            }


            boolean isPalindrome = true;
            while (!queue.isEmpty()) {
                if (queue.dequeue().equals(stack.pop())) {
                    continue;
                } else {
                    isPalindrome = false;
                    break;
                }
            }
            if (!isPalindrome) {
                System.out.println("Not a Palindrome");
            } else {
                System.out.println("Palindrome");
            }
        }
    }
}